package xxl.signals.impl.valuelists 
{
	/**
	 * ...
	 * @author XXL
	 */
	public class ArrayValueList 
	{
		public static const NIL:ArrayValueList = new ArrayValueList(null, null);
		
		public var head:Array;
		public var tail:ArrayValueList;
		public var nonEmpty:Boolean = false;
		
		public function ArrayValueList(head:Array, tail:ArrayValueList = null) 
		{
			if (!head && !tail)
			{
				if (NIL)
				{
					throw new ArgumentError("head不能为空");
				}
				nonEmpty = false;
			}
			else if (!head)
			{
				throw new ArgumentError("head不能为空");
			}
			else
			{
				this.head = head;
				this.tail = tail || NIL;
				nonEmpty = true;
			}
		}
		
		public function prepend(arr:Array):ArrayValueList
		{
			return new ArrayValueList(arr, this);
		}
		
	}

}